Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
How to fix the error "Invalid hook call. Hooks can only be called inside of the body of a function component." in next js

I want to fetch data from my data from firebase database with uesEffect hook but it gives an error message that Error: Invalid hook call. Hooks can only be called inside of the body of a function component. How can i fix this any advice.Thanks in advance. My code is here

     useEffect(()=>{
            console.log("session",session)
        },[session]);
    
        const [myChats]=useCollection(db.collection('chats').where('users','array-contains',session.user.email));
    
        useEffect(()=>{
          myChats?.docs?.map((user)=>{
            setMyChat((prevState)=>[...prevState,user.id])
            useCollection(db.collection('chats').doc(id).collection('messeges').orderBy('timestamp','asc').limitToLast(1)).then(function(chat){
                console.log("chat",chat.id);
                setChats((prev)=>[...prev,chat]);
            })
        })
      },[myChats]);
        
       //   useEffect(()=>{
 // chats?.map((chat,i)=>{
 //     
 //        console.log("id",chat.id);
 //        console.log("photo",chat.data().photoURL);
 //        console.log("email",chat.data().user);
 //        console.log("chat",chat.data().message)
 //    })
 //    },[myChats])
         console.log("myChat",chats)
             
       
       
    
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda